<template>
    <view class="container purchase-detial" v-if="data">
        <header-bar :config="config"></header-bar>
        <view class="detail-card">
            <view class="detial-title">
                <text>商品清单</text>
            </view>
            <view class="detail-info noPb">
                <purchase-pro-item
                    v-for="(item, index) in data.InModel.SkuList"
                    :key="index"
                    :item="item"></purchase-pro-item>
            </view>
        </view>
        <view class="detail-card">
            <view class="detial-title">
                <text>物流信息</text>
            </view>
            <view class="detail-info">
                <easy-label-value
                    label="配送方式:"
                    :value="
                        data.BuyModel.Address && data.BuyModel.Address.ExpressName
                            ? data.BuyModel.Address.ExpressName
                            : ''
                    "></easy-label-value>
                <easy-label-value
                    label="物流单号:"
                    :value="
                        data.BuyModel.Address && data.BuyModel.Address.ExpressNo ? data.BuyModel.Address.ExpressNo : ''
                    "></easy-label-value>
            </view>
        </view>
        <view class="detail-card">
            <view class="detial-title">
                <text>订单信息</text>
            </view>
            <view class="detail-info">
                <easy-label-value label="入库单号:" :value="data.InModel.StockInSn"></easy-label-value>
                <easy-label-value label="入库时间:" :value="data.InModel.StockInTime"></easy-label-value>
                <easy-label-value label="采购单号:" :value="data.BuyModel.OrderNo"></easy-label-value>
                <easy-label-value label="采购时间:" :value="data.BuyModel.AddTime"></easy-label-value>
                <easy-label-value label="发货时间:" :value="data.BuyModel.AddTime"></easy-label-value>
                <easy-label-value label="供应商:" :value="data.InModel.SupplierName"></easy-label-value>
                <easy-label-value
                    label="寄件人:"
                    :value="
                        data.BuyModel.SupplierModel && data.BuyModel.SupplierModel.ContactName
                            ? data.BuyModel.SupplierModel.ContactName
                            : ''
                    "></easy-label-value>
                <easy-label-value
                    label="寄件地址:"
                    :value="getAddressText(data.BuyModel.SupplierModel)"></easy-label-value>
            </view>
        </view>
        <view class="bottom-bar action-bottom-bar" v-if="false">
            <purchase-action></purchase-action>
        </view>
    </view>
</template>

<script>
import easyLabelValue from "@/components/easy/easy-label-value.vue"
import purchaseProItem from "@/pages_work/components/purchase/purchase-pro-item.vue"
import purchaseAction from "@/pages_work/components/purchase/purchase-action.vue"
import { BuyOrderStockInInfo, GetBuyOrdStockOutInfo } from "@/service/api/buyOrder.js"
export default {
    components: {
        easyLabelValue,
        purchaseProItem,
        purchaseAction,
    },
    data() {
        return {
            config: {
                title: "入库详情",
                centerSlot: true,
                color: ["#ffffff"],
                statusBarFontColor: "#ffffff",
            },
            isWait: false,
            data: null,
            id: 0,
        }
    },
    created() {
        let mainColor = this.easyGetColor("main")
        this.config.backgroundColor = [1, mainColor]
    },
    mounted() {
        this.getData()
    },
    onLoad(e) {
        if (e.id) {
            this.id = e.id
        }
    },
    methods: {
        getData() {
            let param = {
                id: this.id,
            }
            let path = "?id=" + this.id
            BuyOrderStockInInfo(param, path).then((res) => {
                if (res.State == 1) {
                    this.data = res.Data
                } else {
                    this.easyToast(res.Msg)
                }
            })
        },
        getAddressText(data) {
            if (!data) {
                return ""
            }
            let ProvinceName = data.ProvinceName ? data.ProvinceName : ""
            let CityName = data.CityName ? data.CityName : ""
            let AreaName = data.AreaName ? data.AreaName : ""
            let StreetName = data.StreetName ? data.StreetName : ""
            let ContactAddress = data.ContactAddress ? data.ContactAddress : ""
            return `${ProvinceName}${CityName}${AreaName}${StreetName}${ContactAddress}`
        },
    },
}
</script>

<style lang="scss">
.container {
    padding-bottom: $app-page-padding;
}
</style>
